<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@taglib prefix="a4j" uri="http://richfaces.org/a4j"%>
<%@taglib prefix="rich" uri="http://richfaces.org/rich"%>
<f:subview id="step1" >
    <h:panelGrid columns="3" id="uno" >
        <f:facet name="header" >
            <h:outputText value="#{msg.dati_personali} (1/5)" />
        </f:facet>

        <h:outputText value="#{msg.name}" />
        <h:inputText  value="#{convalidaPaziente.nome}" id="nome" required="true" requiredMessage="#{msg.required_text_error}" validatorMessage="#{msg.string_validator}">
            <f:validator validatorId="StringValidator" />
        </h:inputText>
        <h:message for="nome" errorClass="error-message"/>

        <h:outputText value="#{msg.surname}" />
        <h:inputText value="#{convalidaPaziente.cognome}" id="cognome" required="true" requiredMessage="#{msg.required_text_error}" validatorMessage="#{msg.string_validator}">
            <f:validator validatorId="StringValidator" />
        </h:inputText>
        <h:message for="cognome" errorClass="error-message"/>

        <h:outputText value="#{msg.sex}" />
        <h:selectOneRadio required="true" value="#{convalidaPaziente.maschio}" 
                          id="sex"
                          requiredMessage="#{msg.required_radio_erro}">
            <f:selectItem itemValue="1" itemLabel="M" />
            <f:selectItem itemValue="0" itemLabel="F" />
        </h:selectOneRadio>
        <h:message for="sex" errorClass="error-message"/>

        <h:outputText value="#{msg.Username}"/>
        <h:inputText value="#{convalidaPaziente.username}" id="username" required="true" 
                     requiredMessage="#{msg.required_text_error}" 
                     validatorMessage="#{msg.username_validation}">
            <f:validator validatorId="UsernameValidator" />
            <f:validator validatorId="StringValidator" />
        </h:inputText>
        <h:message for="username" errorClass="error-message"/>

        <h:outputText value="#{msg.Password}"/>
        <h:inputText value="#{convalidaPaziente.password}" id="password" required="true" requiredMessage="#{msg.required_text_error}"  validatorMessage="#{msg.string_validator}">
            <f:validator validatorId="StringValidator" />
        </h:inputText>
        <h:message for="password" errorClass="error-message"/>

        <h:outputText value="#{msg.birthdate}"/>
        <h:inputText id="data_nascita" value="#{convalidaPaziente.data_nascita}" required="true" 
                     converterMessage="#{msg.wrong_value}"
                     requiredMessage="#{msg.required_text_error}">
            <f:convertDateTime pattern="dd/MM/yyyy" />
        </h:inputText>
        <rich:message for="data_nascita" errorClass="error-message"/>

        <h:outputText value="#{msg.birthplace}"/>
        <h:inputText value="#{convalidaPaziente.luogo_nascita}" id="birthplace" required="true" requiredMessage="#{msg.required_text_error}"  validatorMessage="#{msg.string_validator}">
            <f:validator validatorId="StringValidator" />
        </h:inputText>
        <h:message for="birthplace" errorClass="error-message"/>

        <h:outputText value="#{msg.adress}"/>
        <h:inputText value="#{convalidaPaziente.indirizzo}" id="address" required="true" requiredMessage="#{msg.required_text_error}"  validatorMessage="#{msg.string_validator}">
            <f:validator validatorId="StringValidator" />
        </h:inputText>
        <h:message for="address" errorClass="error-message"/>

        <h:outputText value="#{msg.postal_code}"/>
        <h:inputText value="#{convalidaPaziente.cap}" id="cap" required="true" 
                     requiredMessage="#{msg.required_text_error}"
                     converterMessage="#{msg.wrong_cap}"
                     validatorMessage="#{msg.wrong_cap}">
            <f:validateLongRange minimum="10000" maximum="99999" />
        </h:inputText>
        <h:message for="cap" errorClass="error-message"/>

        <h:outputText value="#{msg.lat}"/>
        <h:inputText value="#{convalidaPaziente.latitudine}" id="lat" required="true"
                     requiredMessage="#{msg.required_text_error}"
                     converterMessage="#{msg.wrong_number}" >
            <f:validateDoubleRange maximum="90" minimum="-90" />
        </h:inputText>
        <h:message for="lat" errorClass="error-message"/>

        <h:outputText value="#{msg.lng}"/>
        <h:inputText value="#{convalidaPaziente.longitudine}" id="lng" required="true" 
                     requiredMessage="#{msg.required_text_error}"
                     converterMessage="#{msg.wrong_number}" >
            <f:validateDoubleRange maximum="180" minimum="-180" />
        </h:inputText>
        <h:message for="lng" errorClass="error-message"/>
    </h:panelGrid>
    <h:panelGrid columns="2">
        <h:commandButton action="#{convalidaPaziente.insertLatLng()}" value="inserisci lat lng" />
        <h:commandLink action="next" >
            <img src="/PortaleVisite/resources/img/right.png" style="width: 50px" />
        </h:commandLink>
    </h:panelGrid>

</f:subview>